package cate.game.role.res.compose.msg;

import cate.common.annotation.OperationSetter;
import cate.common.table.d.GDOperation;
import cate.game.GameBody;
import cate.game.client.ClientContext;
import cate.game.client.msg.ClientMsg;
import cate.game.client.msg.MsgConfig;
import cate.game.client.msg.MsgInput;
import cate.game.client.msg.id.MsgIdCompose;
import easy.java.dev.note.NoteField;
import easy.java.practice.errorcode.EcResult;

@ClientMsg(title = "物品合成的请求")
@OperationSetter(value = GDOperation.ITEM_COMPOSE, sub = "id")
public class ItemComposeReq implements MsgInput {
    @NoteField(value = "合成方案id")
    public int id;
    @NoteField(value = "合成数量")
    public int num;

    @Override
    public MsgConfig conf() {
        return MsgIdCompose.ITEM_COMPOSE_REQ;
    }

    @Override
    public void execute(GameBody game, ClientContext cc) {
        EcResult<Void> r = cc.getRole().getRes().composePO.itemCompose.composeItems(id, num);
        if (!r.ok()) {
            game.notice.message(cc.getRole(), r);
        }
    }
}
